package com.yu.crm.service.impl;

import com.yu.crm.domain.pojo.BimDictInfo;
import com.yu.crm.domain.pojo.BimDictItem;
import com.yu.crm.mapper.BimDictInfoMapper;
import com.yu.crm.service.IBimDictInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yxzz.common.helper.DataHelpers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 数据字典表 服务实现类
 * </p>
 *
 * @author pan
 * @since 2020-07-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class BimDictInfoService extends ServiceImpl<BimDictInfoMapper, BimDictInfo> implements IBimDictInfoService {
    @Autowired
    private BimDictItemService dictItemService;

    @Override
    public void addDictInfo(BimDictInfo bimDictInfo) {
        this.save(bimDictInfo);
        List<BimDictItem> items = bimDictInfo.getItems();
        if(DataHelpers.isNotEmpty(items)&&items.size()>0) {
            dictItemService.saveBatch(items);
        }
    }
}
